//
// Created by longyunbo on 6/23/21.
//

#ifndef ANALYSIS_CONSTANTPOOL_H
#define ANALYSIS_CONSTANTPOOL_H
#include "Klass.h"
#include <iostream>

class ConstantPool {

public:
    static const int JVM_CONSTANT_Utf8 = 1 ;
    static const int JVM_CONSTANT_Integer = 3;
    static const int JVM_COMSTANT_Float = 4;
    static const int JVM_CONSTANT_Long = 5;
    static const int JVM_CONSTANT_Double = 6;
    static const int JVM_CONSTANT_Class = 7;
    static const int JVM_CONSTANT_String =8;
    static const int JVM_CONSTANT_Fielref =9;
    static const int JVM_CONSTANT_Methodref =10;
    static const int JVM_CONSTANT_InterfaceMethodref =11;
    static const int JVM_CONSTANT_NameAndType =12;
    static const int JVM_CONSTANT_MethodHandle =15;
    static const int JVM_CONSTANT_MethodType =16;
    static const int JVM_CONSTANT_InvokeDynamic =18;

    Klass _klass;
    void set_Klass(Klass value);
    Klass get_Klass();

    //测试
    void a(){
      printf(" 测试内容 \n ");
    };
public:
    char* _tags;

    short _size;

    short _length;
    void set_length(short value);
    short get_length();
    /**
     *
     * key : 常量池的index
     * value : 统一用long存储
     *  1.指针
     *
     *  2.基本类型
     * */
     long* _container;

    ~ConstantPool();
    //初始化函数
    void initContainer(short size);


    //add_item 存值char*
    void add_item( int i , char tag , char* value );

    //add_item 存储Long
    void add_item( int i , char tag , long value );

    //存储位运算的值
    void add_item( int i , char tag , int value , int ii );

    //取值
    long get_item( int i );

    //得到类名
    long getClassName( int index );


};


#endif //ANALYSIS_CONSTANTPOOL_H
